package game;

import java.awt.*;

/**
 * 描述：飞机类
 *
 * @author wangb
 * @version 1.0
 * create 2018-11-01-23:07
 */
public class Plane extends GameObject{

    boolean isLive = true;


    /**
     * 重写了生成飞机的类
     * @param g
     */
    @Override
    public void drawSelf(Graphics g) {
        //如果活着，画这个
        if(isLive) {

            g.drawImage (img , ( int ) x , ( int ) y , null);//画出物体
            //根据方向进行移动
            if ( left ) {
                x -= speed;
            }
            if ( right ) {
                x += speed;
            }
            if ( up ) {
                y -= speed;
            }
            if ( down ) {
                y += speed;
            }
        }else {

        }
    }

    /**
     * 重写飞机的构造器
     * @param img img
     * @param x x
     * @param y y
     */
    public Plane(Image img,double x,double y){
        this.img = img;
        this.x = x;
        this.y = y;
        this.speed = 6;
        this.height = img.getHeight (null);
        this.width = img.getWidth (null);
    }
}

